
# 生成器表达式

generator = (x ** 2 for x in range(1, 5))
print(generator)
it = iter(generator)  # 获取生成器对象的迭代器
print(next(it))  # 1
print(next(it))  # 4
print(next(it))  # 9
print(next(it))  # 16
print(next(it))  # StopIterator
